home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
CC_C
/
0574.ZIP
/
STRCMP.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-11-20
|
791b
|
52 lines
include compiler.inc
ttl STRCMP, 1.04, 08-30-86, clr
;string function - compares strings, returns - if first smaller,
; 0 if equal, + if first larger.
dseg
cseg
procdef strncmp, <<string1, ptr>, <string2, ptr>, <cnt, word>>
mov cx,cnt
jmp short start
entrdef strcmp
mov cx,7fffh
start:
pushreg
pushds
xor ax,ax
jcxz endit
ldptr si,string1
ldptr di,string2
cld
dec di
cmpr:
lodsb ; check s1 char
inc di
or al,al ; test for EOS
jz eos1
sub al,[di] ; compare to s2 char
jnz getout
loop cmpr ; while equal close loop
getout:
cbw ; on failure extend sign bit
;
jmp short endit ; mismatched
eos1:
sub al,[di] ; 0 if ==, else signed
cbw ; extend sign bit
endit:
pret
pend strncmp
finish
end